package com.huawei.appgallery.updatemanager.ui.cardkit.card;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.MaskImageView;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import com.huawei.appgallery.updatemanager.ui.cardkit.bean.UpdateRecordCardBean;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import huawei.widget.HwButton;
import o.azb;
import o.cdb;
import o.cdg;
import o.cep;
import o.cgz;
import o.cil;
import o.cim.a;
import o.cke;
import o.cku;
import o.czi;
import o.czk$a;
import o.czk$c;
import o.czk$d;
import o.czk.g;
import o.czu;
import o.dao;
import o.day;
import o.dba;
import o.dbn;
import o.dge.d;
import o.dgh;
import o.ContentManager;
import o.epv;
import o.eqp;
import o.eqx;
import o.MinimumFactory;
import o.evc;
import o.evf;
import o.evk;
import o.ll;

public class UpdateRecordCard extends BaseDistCard implements OnClickListener {
    protected TextView ʻ;
    private b ʻॱ = new b();
    protected TextView ʼ;
    protected ImageView ʽ;
    protected TextView ˊॱ;
    protected UpdateRecordCardBean ˋ;
    protected View ˋॱ;
    protected RelativeLayout ˏॱ;
    protected View ͺ;
    protected TextView ॱˊ;
    private HwButton ॱˋ;
    private LinearLayout ॱˎ;
    protected MaskImageView ॱॱ;
    protected LinearLayout ᐝ;
    protected HwButton ᐝॱ;

    class b {
        final /* synthetic */ UpdateRecordCard ˋ;

        private b(UpdateRecordCard updateRecordCard) {
            this.ˋ = updateRecordCard;
        }

        public void ˎ() {
            if (this.ˋ.ˋ == null || this.ˋ.ʼॱ == null) {
                czi.ˎ.ˊ("UpdateRecordCard", "clickMainLayout, cardBean or context is null!");
            } else if (TextUtils.isEmpty(this.ˋ.ˋ.ॱـ())) {
                czi.ˎ.ˊ("UpdateRecordCard", "clickMainLayout, the packageName is empty!");
            } else {
                int i = g.ʼ;
                String userId = UserSession.getInstance().getUserId();
                String ॱ = eqp.ॱ();
                czu o_czu = (czu) dbn.ˎ(czu.class);
                boolean ˏ = o_czu.ˏ(this.ˋ.ˋ.ॱـ());
                boolean z = o_czu.ॱ(this.ˋ.ˋ.ॱـ(), false, 0) != null;
                if (ˏ) {
                    dgh.onEvent(new d(this.ˋ.ʼॱ, i).ˏ("03|" + userId + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + ॱ).ˋ());
                } else if (z) {
                    dgh.onEvent(new d(this.ˋ.ʼॱ, i).ˏ("02|" + userId + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + ॱ).ˋ());
                } else {
                    dgh.onEvent(new d(this.ˋ.ʼॱ, i).ˏ("04|" + userId + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + ॱ).ˋ());
                }
                UpdateRecordCardBean updateRecordCardBean = this.ˋ.ˋ;
                if (this.ˋ.ˋ.ꞌ()) {
                    z = false;
                } else {
                    z = true;
                }
                updateRecordCardBean.ॱ(z);
                ˎ(this.ˋ.ˋ.ॱـ(), this.ˋ.ˋ.ꞌ());
            }
        }

        private void ˎ(String str, boolean z) {
            if (TextUtils.isEmpty(str)) {
                czi.ˎ.ˊ("UpdateRecordCard", "sendRefreshCardsBroadCast error, packageName = " + str);
                return;
            }
            Intent intent = new Intent();
            intent.putExtra("card_packageName", str);
            intent.putExtra("card_isExpand", z);
            intent.setAction("updatemanager.refresh.update.expand.action");
            ll.ˏ(this.ˋ.ʼॱ).ˋ(intent);
        }

        public void ॱ() {
            if (this.ˋ.ˋ == null || this.ˋ.ʼॱ == null) {
                czi.ˎ.ˊ("UpdateRecordCard", "uninstallApp, cardBean or context is null!");
                return;
            }
            cep.d ˎ = cep.ˎ(this.ˋ.ˋ.ॱـ());
            if (cep.d.ˏ == ˎ) {
                cku ˏ = cku.ˏ(this.ˋ.ʼॱ, cku.class, null, this.ˋ.ʼॱ.getResources().getString(g.ˊˊ));
                ˏ.ˎ(-2, 8);
                ˏ.ॱ(-1, this.ˋ.ʼॱ.getResources().getString(g.ˋॱ));
                ˏ.ˎ(this.ˋ.ʼॱ);
            } else if (cep.d.ˋ == ˎ) {
                evk.ˏ(this.ˋ.ʼॱ, g.ʽॱ, 0).ˋ();
            } else if (dao.ˏ().ˎ() != null) {
                dao.ˏ().ˎ().ˎ(this.ˋ.ˋ);
            }
        }

        public void ˏ() {
            if (this.ˋ.ˋ == null || this.ˋ.ʼॱ == null) {
                czi.ˎ.ˊ("UpdateRecordCard", "ignoreUpdateApp, cardBean or context is null");
            } else {
                dba.ˎ(this.ˋ.ˋ, this.ˋ.ʼॱ);
            }
        }
    }

    public UpdateRecordCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ॱ(view);
        ʽ(view);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        if (cardBean == null || this.ʼॱ == null) {
            czi.ˎ.ˊ("UpdateRecordCard", "setData, data or context is null!");
        } else if (cardBean instanceof UpdateRecordCardBean) {
            this.ˋ = (UpdateRecordCardBean) cardBean;
            super.ˏ(cardBean);
            ˎ();
        } else {
            czi.ˎ.ˊ("UpdateRecordCard", "setData, the data is illegal, can not convert to UpdateRecordCardBean!");
        }
    }

    public void onClick(View view) {
        int id = view.getId();
        if (id == czk$c.ᐝ || id == czk$c.ˉ) {
            this.ʻॱ.ˎ();
        } else if (id == czk$c.ˎˎ) {
            evc.ˊ(view);
            if (dao.ˏ().ˎ() != null) {
                cil.ˋ(this.ʼॱ, new a(this.ˋ).ˋ());
                dao.ˏ().ˎ().ˋ(this.ʼॱ, this.ˋ);
            }
        } else if (id == czk$c.ˊॱ) {
            this.ʻॱ.ॱ();
        } else if (id == czk$c.ॱ) {
            this.ʻॱ.ˏ();
        }
    }

    protected void ॱ(View view) {
        this.ॱˎ = (LinearLayout) view.findViewById(czk$c.ˑ);
        this.ᐝ = (LinearLayout) view.findViewById(czk$c.ˉ);
        this.ᐝ.setOnClickListener(this);
        this.ॱॱ = (MaskImageView) view.findViewById(czk$c.ˎˎ);
        ˊ(view);
        this.ॱॱ.setOnClickListener(this);
        this.ॱॱ.ˊ(2, 1);
        azb.ˋ(view, czk$c.ॱᐝ);
        this.ʻ = (TextView) view.findViewById(czk$c.ˋˋ);
        this.ʼ = (TextView) view.findViewById(czk$c.ॱʻ);
        ˊ((TextView) view.findViewById(czk$c.ˋᐝ));
        this.ॱˊ = (TextView) view.findViewById(czk$c.ʽ);
        this.ˋॱ = view.findViewById(czk$c.ـ);
        azb.ˋ(this.ˋॱ, epv.ᐝ(), azb.ˏ(this.ʼॱ));
        this.ͺ = view.findViewById(czk$c.ͺॱ);
        this.ˏॱ = (RelativeLayout) view.findViewById(czk$c.ᐝ);
        azb.ˋ(this.ˏॱ, epv.ᐝ(), azb.ˏ(this.ʼॱ));
        this.ˏॱ.setOnClickListener(this);
        this.ˊॱ = (TextView) view.findViewById(czk$c.ˏˏ);
        ˎ(view);
        ˋ((DownloadButton) view.findViewById(czk$c.ˏˎ));
        this.ॱˋ = (HwButton) view.findViewById(czk$c.ॱ);
        this.ॱˋ.setOnClickListener(this);
        this.ʽ = (ImageView) view.findViewById(czk$c.ᐝॱ);
    }

    private void ˎ(View view) {
        int ᐝ = epv.ᐝ();
        int ॱ = ((azb.ॱ(this.ʼॱ) - ᐝ) - azb.ˏ(this.ʼॱ)) / 2;
        this.ᐝॱ = (HwButton) view.findViewById(czk$c.ˊॱ);
        this.ᐝॱ.setMaxWidth(ॱ);
        this.ᐝॱ.setOnClickListener(this);
    }

    private void ˊ(View view) {
        azb.ॱ(this.ॱॱ);
    }

    protected void ˎ() {
        ˏ(this.ˋ);
        this.ʻ.setText(this.ˋ.v_());
        ॱ(this.ˋ);
        ˎ(this.ˋ);
        ˋ(this.ˋ);
        this.ॱॱ.setVisibility(0);
        ʽ().setVisibility(0);
        this.ॱˎ.setVisibility(0);
        this.ᐝ.setVisibility(0);
    }

    protected CharSequence ˊ(UpdateRecordCardBean updateRecordCardBean) {
        return day.ˋ(this.ʼॱ, updateRecordCardBean);
    }

    protected void ˎ(UpdateRecordCardBean updateRecordCardBean) {
        if (updateRecordCardBean.ͺ() == 11 || updateRecordCardBean.ͺ() == 12) {
            ˋˊ().setVisibility(8);
        }
    }

    public SpannableString ˏ(BaseCardBean baseCardBean) {
        if (this.ˏ == cke.ॱॱ) {
            return new SpannableString(ContentManager.getInstant().getContext().getString(g.ʻॱ));
        }
        return super.ˏ(baseCardBean);
    }

    protected void ॱ(UpdateRecordCardBean updateRecordCardBean) {
        this.ʼ.setSingleLine(true);
        this.ʼ.setText(ˊ(updateRecordCardBean));
        if (TextUtils.isEmpty(updateRecordCardBean.ᶥ()) && TextUtils.isEmpty(updateRecordCardBean.ㆍ())) {
            this.ॱˊ.setVisibility(0);
            this.ॱˊ.setText(this.ʼॱ.getResources().getString(g.ͺ));
            return;
        }
        ॱॱ(updateRecordCardBean);
    }

    private void ॱॱ(UpdateRecordCardBean updateRecordCardBean) {
        if (TextUtils.isEmpty(updateRecordCardBean.ᶥ())) {
            this.ॱˊ.setVisibility(4);
        } else {
            this.ॱˊ.setVisibility(0);
            this.ॱˊ.setText(updateRecordCardBean.ᶥ());
        }
        this.ˊॱ.setVisibility(8);
        if (!TextUtils.isEmpty(updateRecordCardBean.ㆍ())) {
            this.ˊॱ.setVisibility(0);
            this.ˊॱ.setText(updateRecordCardBean.ㆍ());
        }
    }

    protected void ˏ(UpdateRecordCardBean updateRecordCardBean) {
        int parseInt;
        this.ᐝॱ.setVisibility(0);
        if (cep.d.ˏ == cep.ˊ(((cdg) cdb.ॱ(cdg.class)).ᐝ(updateRecordCardBean.ॱـ()))) {
            evf.ˋ(this.ᐝॱ, czk$a.ˎ);
        } else {
            evf.ˋ(this.ᐝॱ, czk$a.ˏ);
        }
        int ˋ = ((cdg) cdb.ॱ(cdg.class)).ˋ(updateRecordCardBean.ॱـ());
        switch (ˋ) {
            case 12:
                this.ᐝॱ.setText(g.ॱ);
                this.ᐝॱ.setClickable(false);
                this.ᐝॱ.setEnabled(false);
                break;
            case 13:
                this.ᐝॱ.setText(g.ˏ);
                this.ᐝॱ.setClickable(false);
                this.ᐝॱ.setEnabled(false);
                break;
            default:
                this.ᐝॱ.setText(g.ˊ);
                this.ᐝॱ.setEnabled(true);
                this.ᐝॱ.setClickable(true);
                break;
        }
        eqx.ˎ(this.ॱॱ, updateRecordCardBean.ॱˌ(), "defaultPresetResourceKey", updateRecordCardBean.ॱـ());
        try {
            parseInt = Integer.parseInt(updateRecordCardBean.ˎˎ());
        } catch (NumberFormatException e) {
            czi.ˎ.ˊ("UpdateRecordCard", e.toString());
            parseInt = 0;
        }
        if (updateRecordCardBean.ꓸ() == parseInt || ˋ == 0) {
            if (this.ॱˋ != null) {
                this.ॱˋ.setVisibility(8);
            }
        } else if (this.ॱˋ != null) {
            this.ॱˋ.setVisibility(0);
        }
    }

    public void ˋ(UpdateRecordCardBean updateRecordCardBean) {
        if (updateRecordCardBean.ꞌ()) {
            ʽ(updateRecordCardBean);
        } else {
            ᐝ(updateRecordCardBean);
        }
    }

    private void ᐝ(UpdateRecordCardBean updateRecordCardBean) {
        if (this.ˏॱ.getVisibility() != 8) {
            this.ˏॱ.setVisibility(8);
        }
        Drawable ˋ = evf.ˋ(this.ʼॱ, czk$d.ˎ);
        ˋ.setBounds(0, 0, ˋ.getMinimumWidth(), ˋ.getMinimumHeight());
        if (MinimumFactory.getBoolValue(this.ʼॱ)) {
            this.ʼ.setCompoundDrawables(ˋ, null, null, null);
        } else {
            this.ʼ.setCompoundDrawables(null, null, ˋ, null);
        }
        if (updateRecordCardBean.ﾟ() || updateRecordCardBean.ॱᐨ()) {
            this.ˋॱ.setVisibility(8);
        } else {
            this.ˋॱ.setVisibility(0);
        }
    }

    private void ʽ(UpdateRecordCardBean updateRecordCardBean) {
        ˊ();
        this.ˏॱ.setVisibility(0);
        Drawable ˋ = evf.ˋ(this.ʼॱ, czk$d.ॱ);
        ˋ.setBounds(0, 0, ˋ.getMinimumWidth(), ˋ.getMinimumHeight());
        if (MinimumFactory.getBoolValue(this.ʼॱ)) {
            this.ʼ.setCompoundDrawables(ˋ, null, null, null);
        } else {
            this.ʼ.setCompoundDrawables(null, null, ˋ, null);
        }
        this.ˋॱ.setVisibility(8);
        if (updateRecordCardBean.ﾟ() || updateRecordCardBean.ॱᐨ()) {
            this.ͺ.setVisibility(8);
        } else {
            this.ͺ.setVisibility(0);
        }
    }

    private void ˊ() {
    }
}
